package hu.myai.tick;

import hu.myai.api.tick.AbstractTickProvider;
import hu.myai.model.TickVO;
import hu.myai.model.db.AxHistory;
import hu.myai.util.CommonUtil;
import hu.myai.util.db.QueryAsxHistoryData;

import java.util.Date;
import java.util.List;

/**
 * @author bozbalint
 * 
 */
public class PersistedHistoryTick extends AbstractTickProvider {

	public PersistedHistoryTick(String name) {
		super(name);
	}

	private String symbol;

	private Date initDate = CommonUtil.parseDate("2009-01-01");

	public static void main(String[] args) {
		PersistedHistoryTick tickManager = new PersistedHistoryTick("PersistedHistoryTick");

		tickManager.symbol = "BHP";

		tickManager.start();
	}

	public void start() {

		QueryAsxHistoryData asxDB = new QueryAsxHistoryData();
		List<AxHistory> axHistoryList = asxDB.getSavedHistoryList(initDate, symbol, 1500);

		int i = 0;
		for (AxHistory ax : axHistoryList) {

			TickVO tick = new TickVO(ax.getOpen(), ax.getHigh(), ax.getLow(), ax.getClose(), ax.getVolume(), ax.getDate(), i++);

			propegateTick(tick);
		}
	}

	@Override
	public String getSymbol() {
		return symbol;
	}
}
